<?xml version="1.0" encoding="UTF-8" ?>
  
<xsl:stylesheet version="2.0" xmlns="http://knowlysis.com/pdf2xml/TOKEN" xmlns:pdf2xml="http://knowlysis.com/pdf2xml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:f="functions" exclude-result-prefixes="xs xsi f pdf2xml">
	<xsl:output method="text" encoding="UTF-8" indent="yes" />
	
	<xsl:variable name="filters" select="document('../xml/Filter.xml')/root/*"/>
	
	<xsl:template match="/root">
		<xsl:text><![CDATA[package org.computate.guice;

import org.computate.controller.filter.Filter_page;
import org.computate.controller.filter.form.FilterFormRequestAppointment;
import org.computate.controller.filter.form.FilterFormRequestAppointmentSubmit;
import org.computate.controller.filter.UserFilter;
import org.computate.controller.filter.item.Upload.FilterUploadProcessPhoto;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import com.google.inject.Singleton;
import com.google.inject.servlet.ServletModule;
import com.googlecode.objectify.ObjectifyService;
]]></xsl:text>
		<xsl:for-each select="item">
			<xsl:variable name="item" select="."/>
			
			<xsl:text><![CDATA[import org.computate.model.item.]]></xsl:text>
			<xsl:value-of select="."/>
			<xsl:text><![CDATA[;
]]></xsl:text>

			<xsl:for-each select="$filters">
				<xsl:text><![CDATA[import org.computate.controller.filter.item.]]></xsl:text>
				<xsl:value-of select="$item"/>
				<xsl:text><![CDATA[.Filter]]></xsl:text>
				<xsl:value-of select="$item"/>
				<xsl:value-of select="."/>
				<xsl:text><![CDATA[;
]]></xsl:text>
			</xsl:for-each>
		</xsl:for-each>
		<xsl:text><![CDATA[

public class MyServletModule extends ServletModule {
	
	@Override
	protected void configureServlets() {
		bind(ConfigurableSiteMeshFilter.class).in(Singleton.class);
		filter("/page/*").through(ConfigurableSiteMeshFilter.class);
		filter("/fragment/*").through(ConfigurableSiteMeshFilter.class);
		filter("/page/*").through(UserFilter.class);
		filter("/page/").through(Filter_page.class);
		filter("/page/form/RequestAppointment.jsp").through(FilterFormRequestAppointment.class);
		filter("/page/form/RequestAppointmentSubmit.jsp").through(FilterFormRequestAppointmentSubmit.class);
		filter("/page/item/Upload/UploadProcessPhoto.jsp").through(FilterUploadProcessPhoto.class);
]]></xsl:text>
		<xsl:for-each select="item">
			<xsl:variable name="item" select="."/>
			
			<xsl:for-each select="$filters">
				<xsl:text><![CDATA[		filter("/page/item/]]></xsl:text>
				<xsl:value-of select="$item"/>
				<xsl:text><![CDATA[/]]></xsl:text>
				<xsl:value-of select="$item"/>
				<xsl:value-of select="."/>
				<xsl:text><![CDATA[.jsp").through(Filter]]></xsl:text>
				<xsl:value-of select="$item"/>
				<xsl:value-of select="."/>
				<xsl:text><![CDATA[.class);
]]></xsl:text>
			</xsl:for-each>
		</xsl:for-each>
		<xsl:text><![CDATA[		
		]]></xsl:text>
		<xsl:for-each select="item">
			<xsl:text><![CDATA[		ObjectifyService.register(]]></xsl:text>
			<xsl:value-of select="."/>
			<xsl:text><![CDATA[.class);
]]></xsl:text>
		</xsl:for-each>
		<xsl:text><![CDATA[	}
}
]]></xsl:text>
	</xsl:template>
</xsl:stylesheet>
